using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace WindowsGame1
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        Bola bola;
        Palheta paletaEsquerda;
        Palheta paletaDireita;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        //Window.ClientBounds.width/2 --> meio da tela

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();
        }


        public float CalcularMedia(int nota1, int nota2)
        {
           
          
            float resultado;

            resultado = (nota1 + nota2) / 2;

            Console.WriteLine(resultado);

            return resultado;
        }


        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {

            //objeto = new Objeto2D(Content.Load<Texture2D>("Kurt_Cobain"));
            bola = new Bola(Content.Load<Texture2D>("bola"));
            paletaEsquerda = new Palheta(Content.Load<Texture2D>("paleta"));
            paletaDireita = new Palheta(Content.Load<Texture2D>("paleta"));

            bola.posicao = new Vector2(300,400);
            paletaEsquerda.posicao = new Vector2(0,200);
            paletaDireita.posicao = new Vector2(770, 200);


            float mediaAluno;

            Random aleatorio = new Random();

            

            mediaAluno = CalcularMedia(aleatorio.Next(10), aleatorio.Next(10)  );
            spriteBatch = new SpriteBatch(GraphicsDevice);
            //Console.WriteLine(mediaAluno);

        }
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();
            bola.posicao.X += 1;

            base.Update(gameTime);
        }
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here
            spriteBatch.Begin();

            //objeto.Draw(spriteBatch);
            bola.Draw(spriteBatch);
            paletaEsquerda.Draw(spriteBatch);
            paletaDireita.Draw(spriteBatch);

            spriteBatch.End();



            base.Draw(gameTime);
        }
    }
}
